Catch parsing errors in xm create.
authorxenrtd@shispar-rt.testdev.hq.xensource.com <xenrtd@shispar-rt.testdev.hq.xensource.com>
Mon, 21 Nov 2005 17:52:40 +0000 (18:52 +0100)
committerxenrtd@shispar-rt.testdev.hq.xensource.com <xenrtd@shispar-rt.testdev.hq.xensource.com>
Mon, 21 Nov 2005 17:52:40 +0000 (18:52 +0100)
tools/python/xen/xm/create.py
tools/python/xen/xm/help.py

index 6d90f85d0365e0bb984dc58f1816afc865f5bf2d..8bf3c5f6ef1a95de973957afca638d6b786a0878 100644 (file)
@@ -909,7 +909,10 @@ def parseCommandLine(argv):
 
 
 def main(argv):
-    (opts, config) = parseCommandLine(argv)
+    try:
+        (opts, config) = parseCommandLine(argv)
+    except StandardError, ex:
+        err(str(ex))
 
     if not opts:
         return
@@ -924,8 +927,7 @@ def main(argv):
         dom0_min_mem = xroot.get_dom0_min_mem()
         if dom0_min_mem != 0:
             if balloon_out(dom0_min_mem, opts):
-                print >>sys.stderr, "error: cannot allocate enough memory for domain"
-                sys.exit(1)
+                err("cannot allocate enough memory for domain")
 
         dom = make_domain(opts, config)
         if opts.vals.console_autoconnect:
index 276cfbbf4aff54303ef21d1a640e30ae8536351a..9db2e31fdf02cf2404dfbc9880fdc4f5dfde41b6 100644 (file)
@@ -87,7 +87,10 @@ class Var:
         """Execute the check and set the variable to the new value.
         """
         if not self.check: return
-        env[self.name] = self.check(self.name, env.get(self.name))
+        try: 
+            env[self.name] = self.check(self.name, env.get(self.name))
+        except StandardError, ex:
+            raise sys.exc_type, self.name + " - " + str(ex)
 
     def doHelp(self, out):
         """Print help for the variable.